//
//  UIManager.m
//  RadioApp
//
//  Created by Ryan Enguero on 5/8/14.
//  Copyright (c) 2014 engueroryan. All rights reserved.
//

#import "UIManager.h"

#import "ListenViewController.h"
#import "ShowsViewController.h"
#import "EventsViewController.h"
#import "SocialViewController.h"
#import "WebsiteViewController.h"

static UIManager *sharedItem = nil;

@implementation UIManager

- (UITabBarController*)tabBarController{

    self.listenView = [[ListenViewController alloc] initWithNibName:@"ListenViewController" bundle:nil];
    self.showsView = [[ShowsViewController alloc] initWithNibName:@"ShowsViewController" bundle:nil];
    self.eventsView = [[EventsViewController alloc] initWithNibName:@"EventsViewController" bundle:nil];
    self.socialView = [[SocialViewController alloc] initWithNibName:@"SocialViewController" bundle:nil];
    self.websiteView = [[WebsiteViewController alloc] initWithNibName:@"WebsiteViewController" bundle:nil];
    
    UINavigationController *navBarListenView = [[UINavigationController alloc] initWithRootViewController:self.listenView];
    
    [navBarListenView.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBarImg.png"] forBarMetrics:UIBarMetricsDefault];
    
    UINavigationController *navBarShowsView = [[UINavigationController alloc] initWithRootViewController:self.showsView];
    
    [navBarShowsView.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBarImg.png"] forBarMetrics:UIBarMetricsDefault];
    
    UINavigationController *navBarEventsView = [[UINavigationController alloc] initWithRootViewController:self.eventsView];
    
    [navBarEventsView.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBarImg.png"] forBarMetrics:UIBarMetricsDefault];
    
    UINavigationController *navBarSocialView = [[UINavigationController alloc] initWithRootViewController:self.socialView];
    
    [navBarSocialView.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBarImg.png"] forBarMetrics:UIBarMetricsDefault];
    
    UINavigationController *navBarWebsite = [[UINavigationController alloc] initWithRootViewController:self.websiteView];
    
    [navBarWebsite.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBarImg.png"] forBarMetrics:UIBarMetricsDefault];
    
    UITabBarController *tabBar = [[UITabBarController alloc] init];
    
    tabBar.viewControllers = @[navBarListenView, navBarShowsView, navBarEventsView, navBarSocialView, navBarWebsite];
    
    tabBar.selectedViewController = navBarListenView;
    
    [navBarListenView.tabBarItem setImage:[UIImage imageNamed:@"listenTabImg.png"]];
    [navBarShowsView.tabBarItem setImage:[UIImage imageNamed:@"showsTabImg.png"]];
    [navBarEventsView.tabBarItem setImage:[UIImage imageNamed:@"eventsTabImg.png"]];
    [navBarSocialView.tabBarItem setImage:[UIImage imageNamed:@"socialTabImg.png"]];
    [navBarWebsite.tabBarItem setImage:[UIImage imageNamed:@"websiteTabImg.png"]];

    [tabBar.tabBar setBackgroundImage:[UIImage imageNamed:@"tabBarImg.png"]];
  //  [tabBar.tabBar setTintColor:[UIColor whiteColor]];
    [tabBar.tabBar setSelectedImageTintColor:[UIColor whiteColor]];
    
    return tabBar;
}





#pragma mark - SingleTon

+ (UIManager *)sharedItems
{
    if (sharedItem == nil) {
        sharedItem = [[super allocWithZone:NULL]init];
    }
    return  sharedItem;
}
- (id)init{
    if ((self = [super init])) {
        
    }
    return self;
}
+ (id)allocWithZone:(NSZone *)zone{
    return  [self sharedItems];
}
- (id)copyWithZone:(NSZone *)zone{
    return self;
}


@end